home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
cenvid
/
screen.lib
< prev
next >
Wrap
Text File
|
1995-03-28
|
10KB
|
283 lines
//**********************************************************************
//*** Screen.lib - A library of useful utilities for writing to the ***
//*** ver.3 screen. For when the internal CEnviD Screenxxx() ***
//*** routines are not enough. ***
//***
//***
//**** SetCursor(): Set cursor at screen Row and Column
// SYNTAX: void SetCursor(int Row,int Col)
//
//**** GetCursor(): Get current cursor position
// SYNTAX: void GetCursor(int Row,int Col)
//
//**** ScrWrite(): Write string or character, position, and attributes
// SYNTAX: void ScrWrite(string Text or byte Char)
// void ScrWrite(string Text or byte Char,int Row,int Col)
// void ScrWrite(string Text or byte Char,int Row,int Col,int ForeColor,int BackColor)
// WHERE: Text - Character string to write
// Row, Col - Cursor position; if not supplied then current position
// ForeColor, BackColor - Attributes for string, else current attributes
#define BLACK 0
#define BLUE 1
#define GREEN 2
#define CYAN 3
#define RED 4
#define MAGENTA 5
#define BROWN 6
#define LIGHTGRAY 7
#define DARKGRAY 8
#define LIGHTBLUE 9
#define LIGHTGREEN 10
#define LIGHTCYAN 11
#define LIGHTRED 12
#define LIGHTMAGENTA 13
#define YELLOW 14
#define WHITE 15
#define BLINK 0x8 // OR with background color to make blink
//
//**** Clear(): Clear screen
// SYNTAX: void Clear()
// void Clear(ForeColor,BackColor)
//
//**** Scroll(): Scroll a region of the screen
// SYNTAX: void Scroll(LineCount)
// void Scroll(LineCount,TopRow,LeftCol,BottomRow,RightCol)
// void Scroll(LineCount,ForeColor,BackColor)
// void Scroll(LineCount,TopRow,LeftCol,BottomRow,RightCol,ForeColor,BackColor)
//
//**** TextBox()
// SYNTAX: void TextBox(TopRow,LeftCol,BottomRow,RightCol)
// void TextBox(TopRow,LeftCol,BottomRow,RightCol,Treatment)
// void TextBox(TopRow,LeftCol,BottomRow,RightCol,ForeColor,BackColor)
// void TextBox(TopRow,LeftCol,BottomRow,RightCol,ForeColor,BackColor,Treatment)
// WHERE: Treatment is a character to use as the border (e.g. '*') or'ed with one of the following
#define DOUBLE_LINE 0x100 // Use double-line graphics characters
#define SINGLE_LINE 0x200 // use single-line graphics characters around box
#define SHADOW 0x400 // drop down a shadow from the box to desktop
#define NOFILL 0x800 // only draw border
//
//**** ReadCharacter()
// SYNTAX: byte ReadCharacter()
// byte ReadCharacter(int Attribute)
// byte ReadCharacter(int Row,int Col)
// byte ReadCharacter(int Row,int Col,int Attribute)
//
//
//**** GetScreenData() - Read screen text into one single array
// SYNTAX byte[] ReadScreen()
// RETURN: An array is returned of screenwidth * screenheight bytes containing
// the contents of the screen; No attempt is made to turn NULLs into
// spaces or to end lines
//
//
//**** SetCursorType()
// SYNTAX: void SetCursorType(int Cursor)
// void SetCursrorType(int StartingLine,int EndingLine)
#define HIDE_CURSOR 0xFFFF
//
//**** GetCursorType()
// SYNTAX: int GetCursorType()
//
//**** SetAttribute()
// SYNTAX: void SetAttribute(int Attribute)
// void SetAttribute(int ForeColore,int BackColor)
//
//**** HorzLine(): Draw a horizontal line
// SYNTAX: void HorzLine(Row,LeftCol,Treatment)
// void HorzLine(Row,LeftCol,Len,ForeColor,BackColor,Treatment)
// WHERE: Treatment is SINGLE_LINE, DOUBLE_LINE, or character to draw with
//
//**** VertLine(): Draw a vertical line
// SYNTAX: void VertLine(TopRow,Col,Treatment)
// void VertLine(TopRow,Col,Len,ForeColor,BackColor,Treatment)
// WHERE: Treatment is SINGLE_LINE, DOUBLE_LINE, or character to draw with
//
//
//
slForeColor = LIGHTGRAY;
slBackColor = BLACK;
SetCursor(pRow,pCol)
{
reg.ah = 2, reg.bh = 0, reg.dh = pRow, reg.dl = pCol;
interrupt(0x10,reg);
}
GetCursor(pRow,pCol)
{
reg.ah=3, reg.bh=0;
interrupt(0x10,reg);
pRow=reg.dh, pCol=reg.dl;
}
SetCursorType(pStartingLine,pEndingLine)
{
lCursor = ( 1 == va_arg() ) ? pStartingLine : (pStartingLine<<8) | pEndingLine ;
reg.ah=1, reg.cx=lCursor;
interrupt(0x10,reg);
}
GetCursorType()
{
reg.ah=3, reg.bh=0;
interrupt(0x10,reg);
return reg.cx;
}
SetAttribute(pForeColor,pBackColor)
{
if ( 1 == va_arg() )
slForeColor = pForeColor & 0xF, slBackColor = (pForeColor & 0xF0) >> 4;
else
slForeColor = pForeColor, slBackColor = pBackColor;
}
ReadCharacter(pRow,pCol,pAttr)
{
if ( 1 < va_arg() ) SetCursor(pRow,pCol);
reg.ah=8, reg.bh=0;
interrupt(0x10,reg);
if ( 1 == va_arg() ) pRow = reg.ah;
else if ( 3 == va_arg() ) pAttr = reg.ah;
return byte(reg.al);
}
ScrWrite(pStrOrChar,pRow,pCol,pForeColor,pBackColor)
{
if ( 3 < va_arg() ) slForeColor = pForeColor, slBackColor = pBackColor;
if ( !DataDimension(pStrOrChar) ) {
// write a single character
if ( 1 < va_arg() ) ScreenCursor(pCol,pRow);
reg.ah=9, reg.cx=1, reg.al=pStrOrChar;
} else {
// write a string
if ( 1 < va_arg() ) reg.dh=pRow, reg.dl=pCol;
else GetCursor(reg.dh,reg.dl);
reg.ax=0x1301, reg.cx=strlen(pStrOrChar);
reg.es=segment(pStrOrChar), reg.bp=offset(pStrOrChar);
}
reg.bx=slForeColor|(slBackColor<<4);
interrupt(0x10,reg);
}
Clear(pForeColor,pBackColor)
{
if ( 2 == va_arg() ) slForeColor = pForeColor, slBackColor = pBackColor;
lSize = ScreenSize();
Scroll(0,0,0,lSize.row-1,lSize.col-1);
}
Scroll(pLineCount,pTopRow,pLeftCol,pBottomRow,pRightCol,pForeColor,pBackColor)
{
if ( pLineCount < 0 ) reg.ah=6, reg.al=-pLineCount;
else reg.ah=7, reg.al=pLineCount;
if ( 3 < va_arg() ) reg.ch=pTopRow, reg.cl=pLeftCol, reg.dh=pBottomRow, reg.dl=pRightCol;
else reg.ch=reg.cl=0, reg.dh=ScreenSize().row-1, reg.dl=ScreenSize().col-1;
if ( 3 == va_arg() ) slForeColor = pTopRow, slBackColor = pLeftCol;
else if ( 5 < va_arg() ) slForeColor = pForeColor, slBackColor = pBackColor;
reg.bh=slForeColor|(slBackColor<<4);
interrupt(0x10,reg);
}
TextBox(pTopRow,pLeftCol,pBottomRow,pRightCol,pForeColor,pBackColor,pTreatment)
{
lSaveCursor = GetCursorType();
SetCursorType(HIDE_CURSOR);
if ( 5 < va_arg() ) slForeColor = pForeColor, slBackColor = pBackColor;
lTreatment = ( 1 & va_arg() ) ? lTreatment = va_arg(va_arg()-1) : 0 ;
// If supposed to fill the entire box then do whole box now
if !(lTreatment & NOFILL)
Scroll(0,pTopRow,pLeftCol,pBottomRow,pRightCol);
if ( lTreatment & Shadow ) {
lSaveFore = slForeColor, lSaveBack = slBackColor;
Scroll(0,pTopRow+1,pRightCol+1,pBottomRow+1,pRightCol+2,LIGHTGRAY,BLACK);
Scroll(0,pBottomRow+1,pLeftCol+2,pBottomRow+1,pRightCol,LIGHTGRAY,BLACK);
slForeColor = lSaveFore, slBackColor = lSaveBack;
}
// if need lines, then draw lines now
if ( lLineType = (lTreatment & (DOUBLE_LINE|SINGLE_LINE|0xFF)) ) {
if ( lLineType & 0xFF )
memset(lCorners,lLineType,4);
else
lCorners = SINGLE_LINE==lLineType ? '┌┐└┘' : '╔╗╚╝' ;
ScrWrite(lCorners[0],pTopRow,pLeftCol);
HorzLine(pTopRow,pLeftCol+1,lLen=pRightCol-pLeftCol-1,lLineType);
ScrWrite(lCorners[1]);
ScrWrite(lCorners[2],pBottomRow,pLeftCol);
HorzLine(pBottomRow,pLeftCol+1,lLen,lLineType);
ScrWrite(lCorners[3]);
VertLine(pTopRow+1,pLeftCol,lLen=pBottomRow-pTopRow-1,lLineType);
VertLine(pTopRow+1,pRightCol,lLen,lLineType);
}
SetCursorType(lSaveCursor);
}
HorzLine(pRow,pLeftCol,pLen,pForeColor,pBackColor,pTreatment)
{
if ( 4 < va_arg() ) slForeColor = pForeColor, slBackColor = pBackColor;
lTreatment = va_arg(va_arg()-1);
if ( lTreatment & 0xFF )
// fill line with plain text character
memse